package com.api.shopapi.service.impl;

import com.api.shopapi.entity.JKXuezhi;
import com.api.shopapi.entity.dto.JKXuezhiDTO;
import com.api.shopapi.mapper.JKXuezhiMapper;
import com.api.shopapi.service.JKXuezhiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("JKXuezhiServiceImplOne")
public class JKXuezhiServiceImpl implements JKXuezhiService {

    @Autowired
    private JKXuezhiMapper jkXuezhiMapper;

    @Override
    public int insert(JKXuezhi jkXuezhi) {
        return jkXuezhiMapper.insert(jkXuezhi);
    }

    @Override
    public int update(JKXuezhi jkXuezhi) {
        return jkXuezhiMapper.update(jkXuezhi);
    }

    @Override
    public int delete(String jKXuezhiCode) {
        return jkXuezhiMapper.delete(jKXuezhiCode);
    }

    @Override
    public JKXuezhi getByJKXuezhiCode(String jKXuezhiCode) {
        return jkXuezhiMapper.getByJKXuezhiCode(jKXuezhiCode);
    }

    @Override
    public PageInfo<JKXuezhi> getPageList(int pageIndex, int pageSize, String userCode,String startTime,String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKXuezhi> xuezhiList = jkXuezhiMapper.getPageList(userCode,startTime,endTime);
        return new PageInfo<>(xuezhiList);
    }

    @Override
    public PageInfo<JKXuezhiDTO> getAdmPageList(int pageIndex, int pageSize, String name, String governmentCode, String startTime, String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKXuezhiDTO> xuezhiDTOList = jkXuezhiMapper.getAdmPageList(name, governmentCode, startTime, endTime);
        return new PageInfo<>(xuezhiDTOList);
    }
}
